package com.ruoyi.web.controller.excimport;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.construction.service.IConstructionSiteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author sunli
 * @date 2025/1/6 17:06
 * @desc
 **/
@RestController
@RequestMapping("/excelImport")
public class ExcelImportController {


    @Autowired
    private IConstructionSiteService constructionSiteService;

    /**
     * 项目导入
     */
    @PostMapping("/project")
    public AjaxResult projectDate(@RequestPart("file") MultipartFile file)
    {
        try {
            constructionSiteService.projectDate(file);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return AjaxResult.success();
    }

    /**
     * 项目更新
     */
    @PostMapping("/projectUpdate")
    public AjaxResult projectUpdate(@RequestPart("file") MultipartFile file)
    {
        try {
            constructionSiteService.projectUpdate(file);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return AjaxResult.success();
    }


    /**
     * 处置场所
     */
    @PostMapping("/disposalsSite")
    public AjaxResult disposalsSite(@RequestPart("file") MultipartFile file)
    {
        try {
            constructionSiteService.disposalsSite(file);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return AjaxResult.success();
    }

    /**
     * 处置场所修改
     */
    @PostMapping("/disposalsSiteUpdate")
    public AjaxResult disposalsSiteUpdate(@RequestPart("file") MultipartFile file)
    {
        try {
            constructionSiteService.disposalsSiteUpdate(file);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return AjaxResult.success();
    }

    /**
     *  同步项目和场所id
     *
     */
    @PostMapping("/changeId")
    public AjaxResult changeId()
    {
        try {
            constructionSiteService.changeId();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return AjaxResult.success();
    }
}
